************************************************************************** 
* Replication of Table 4 of Valdini and Lewis-Beck (2018)
**************************************************************************
clear
local current_path = c(pwd)
set scheme plotplain, permanently
cd "`current_path'"

* 
use "table4.dta", replace

encode countryname, gen(ctry)



* Model 1  Original 
xtset ctry year, yearly
gen gdplag_concurord= concurrentordinal* gdpgrowthlag
xtreg voteincparfirst gdpgrowthlag voteinclagged winstability tradegdp concurrentordinal gdplag_concurord, re robust
est sto m1orig

* Model 1 with DDRLA correct criteria

gen DDRLAdemoc=0
* Argentina 
replace DDRLAdemoc=1 if ctry==1
* Bolivia
replace DDRLAdemoc=1 if ctry==2 & year==2005
* Brazil
replace DDRLAdemoc=1 if ctry==3
*Chile
replace DDRLAdemoc=1 if ctry==4
*Colombia
replace DDRLAdemoc=1 if ctry==5
*Costa Rica 
replace DDRLAdemoc=1 if ctry==6
*Dominican Republic
replace DDRLAdemoc=1 if ctry==7
* Ecuador
replace DDRLAdemoc=1 if ctry==8 & year<2009 
* El Salvador
replace DDRLAdemoc=1 if ctry==9 
* Guatemala
replace DDRLAdemoc=1 if ctry==10
* Honduras
replace DDRLAdemoc=1 if ctry==11 & year<2009
*Mexico
replace DDRLAdemoc=1 if ctry==12 & year>2000
*Nicaragua
replace DDRLAdemoc=1 if ctry==13 & year<2006 
*Panama
replace DDRLAdemoc=1 if ctry==14 & year>1990 
*Paraguay
replace DDRLAdemoc=1 if ctry==15 
* Peru
replace DDRLAdemoc=1 if ctry==16 & year!=1990
replace DDRLAdemoc=0 if ctry==16 & year==1995
* Uruguay
replace DDRLAdemoc=1 if ctry==17 
*Venezuela
replace DDRLAdemoc=1 if ctry==18 & year<=1998

tab DDRLAdemoc

xtreg voteincparfirst gdpgrowthlag voteinclagged winstability tradegdp concurrentordinal gdplag_concurord if DDRLAdemoc==1, re robust
est sto m1dddrla

esttab m1orig m1dddrla using result_1.rtf, one replace b(2) se(2) wide staraux ///
	star(* 0.10 ** 0.05 *** 0.01) eqlabels(none) nobase  nodep /// 
	label mtitles("Valdini and Lewis Beck Sample""DDRLA") nonumbers note("Clustered standard errors in parentheses.")	 

 